<%@page import="cn.jhc.dao.TitleDAO"%>
<%@page import="cn.jhc.bean.UserBean"%>
<%@page import="cn.jhc.dao.MailDAO"%>
<%@page import="cn.jhc.bean.MailBean"%>
<%@page import="java.util.ArrayList"%>
<%@page import="cn.jhc.dao.ConnectionFactory"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	UserBean user = (UserBean) session.getAttribute("user");
	if (null == user) {
		String getb = (String) request.getParameter("getb");
		RequestDispatcher dispatcher = request
				.getRequestDispatcher("/login.jsp");
		dispatcher.forward(request, response);
		return;
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/mail.css"></link>
<script type="text/javascript">
	function MM_popupMsg(msg) {

		alert(msg);

	}
</script>
<style>
* {
	border: 0;
}
</style>
<title>蓝调吉他社</title>
</head>
<%
	int CurrentPage = 1;
	int titleCount = 10;
	int intPageCount;
	if (request.getParameter("page") != null)
		CurrentPage = Integer.parseInt(request.getParameter("page"));
	if (CurrentPage < 1)
		CurrentPage = 1;
	int MsgCount;
	int mailNum;
%>
<body>
	<div id="wrapper">
		<%
			ArrayList<MailBean> m = new ArrayList<MailBean>();
			MailDAO dao = new MailDAO();
			dao.setCon(ConnectionFactory.getConnection());
			m = dao.getHaveRead(user.getDisplayname(), CurrentPage, titleCount);
			request.setAttribute("havemail", m);
		%>
		<%
			MailDAO dao5 = new MailDAO();
			dao5.setCon(ConnectionFactory.getConnection());
			mailNum = dao5.getMailCount(user.getDisplayname());
		%>
		<%
			MailDAO dao2 = new MailDAO();
			dao2.setCon(ConnectionFactory.getConnection());
			intPageCount = dao2.getCount(titleCount, user.getDisplayname());
			if (intPageCount == 0) {
				CurrentPage = 1;
				intPageCount = 1;
			} else {
				if (CurrentPage > intPageCount)
					CurrentPage = intPageCount;
			}
		%>
		<div id="name">
			欢迎您！会员：${sessionScope.user.displayname}|<a href="index.jsp">回到首页</a>
		</div>
		<div id="allmail_top">
			<a>消息中心</a>
		</div>
		<div id="allmail">
			<div id="mail_left">
				<div id="TabbedPanels1" class="TabbedPanels">
					<ul class="TabbedPanelsTabGroup">
						<li class="TabbedPanelsTab2"><a>普通消息(已阅)</a></li>
						<li class="TabbedPanelsTab"><a href="mailadmin.jsp">管理员消息(已阅)</a></li>
						<li class="TabbedPanelsTab"><a href="mailnot.jsp">未阅览(<%=mailNum%>)</a></li>
					</ul>
					<div class="TabbedPanelsContentGroup">
						<table width="505">
							<c:forEach items="${requestScope.havemail}" var="havemail">
								<tr>
									<td width="505" height="40"><div
											class="TabbedPanelsContent">
											<div id="mail">
												<a href="mailshowcontent.jsp?id=${havemail.id}">用户：${havemail.name}（呢称：${havemail.displayname}）私密你了一条消息
													${havemail.date}</a>
											</div>
											<div id="underline"></div>
										</div></td>
								</tr>
							</c:forEach>
						</table>
					</div>
				</div>
				<div id="mail_left_down">
					<div id="deletemail">
						<a href="deleteMail.do?displayname=<%=user.getDisplayname()%>">删除全部</a>
					</div>
					<div id="page" align="left">
						第<%=CurrentPage%>页 共<%=intPageCount%>页 <a
							href="mailindex.jsp?page=<%=1%>">首页</a>
						<%
							if (CurrentPage > 1) {
						%>
						<a href="mailindex.jsp?page=<%=CurrentPage - 1%>">上一页</a>
						<%
							} else {
						%>
						上一页
						<%
							}
						%>
						<%
							if (CurrentPage >= intPageCount) {
						%>
						下一页
						<%
							} else {
						%>
						<a href="mailindex.jsp?page=<%=CurrentPage + 1%>">下一页</a>
						<%
							}
						%>
						<a href="mailindex.jsp?page=<%=intPageCount%>">末页</a>
					</div>
				</div>
			</div>
			<div id="mail_top">
				<a href="tomail.jsp">发送消息</a>
			</div>
			<div id="mail_right"></div>
		</div>
		<div id="line"></div>
		<div id="copyright">
			<a>版权所有:蓝调吉他社 </a>
		</div>
	</div>
</body>
</html>